﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ListConverters.cs" company="">
//   
// </copyright>
// <summary>
//   The currency list converter.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Systemathics.FrameWork;

namespace Systemathics.UserControls
{
    /// <summary>
    /// The currency list converter.
    /// </summary>
    internal class CurrencyListConverter : TypeConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true; // display drop
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true; // drop-down vs combo
        }

        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var db = new SystemathicsEntities(GlobalVariables.EntitiesConnectionString());
            return new StandardValuesCollection(db.DBCurrency.Select(i => i.Ticker).ToList());
        }
    }
  
    internal class ExchangeListConverter : TypeConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true; // display drop
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true; // drop-down vs combo
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var db = new SystemathicsEntities(GlobalVariables.EntitiesConnectionString());
            return new StandardValuesCollection(db.DBExchange.Select(i => i.ExchangeName).ToList());
        }
    }

    internal class InstrumentListConverter : TypeConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true; // display drop
        }
        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true; // drop-down vs combo
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var db = new SystemathicsEntities(GlobalVariables.EntitiesConnectionString());
            return new StandardValuesCollection(db.DBInstruments.Select(i => i.Name).ToList());
        }
    }


    internal class ProvidersListConverter : TypeConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true; // display drop
        }

        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true; // drop-down vs combo
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var NamesList = new List<string>();

            NamesList.AddRange(ProviderFactory.GetDataProvidersName(GlobalVariables.ASSEMBLY));
            NamesList.AddRange(ProviderFactory.GetOrderProvidersName(GlobalVariables.ASSEMBLY));
            NamesList.AddRange(ProviderFactory.GetMixedProvidersName(GlobalVariables.ASSEMBLY));
            return new StandardValuesCollection(NamesList);
        }
    }
}